package com.tx.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author tx
 * @description  登录操作页
 *                  说明：login(): 1、进入login页面   2.登录错误时也进入该方法
 *                  登录表单中的action，只用在login-Processing-url中配置就可以，不用真实存在
 * @param  * @Param: null
 * @return
**/
@Controller
public class LoginController {

    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login(@RequestParam(value = "error", required = false) String error, Model model) {
        if (error != null) {
            model.addAttribute("msg","用户名或密码错误！");
            return "login";
        }
        model.addAttribute("msg","");
        return "login";
    }

    @RequestMapping("/welcome")
    public String welcome(){
        return "home";
    }
}